package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@Slf4j
@RequestMapping("/setmeal")
@RestController
public class SetmealController {
    @Resource private SetmealService setmealService;

    @GetMapping("/findPage")
    public Result SelectPage(QueryPageBean queryPageBean) {
        PageResult pageResult = setmealService.SelectPage(queryPageBean);
        log.warn("{}", pageResult);
        return new Result(true, MessageConst.ACTION_SUCCESS, pageResult);
    }
    @PostMapping("/add")
    public Result Add(@RequestBody Setmeal setmeal, Integer[] checkgroupIds){
        setmealService.Add(setmeal,checkgroupIds);
        return new Result(true,MessageConst.ACTION_SUCCESS,null);
    }
}
